package com.shijun.im.http;

import com.shijun.im.config.HttpUrlAPI;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;

/**
 * Created by Administrator on 2017/9/12 0012.
 */

public class RetrofitService<T> {

    private Retrofit mRetrofit;
    private static final String BASE_URL = HttpUrlAPI.MAIM_URL;
    private APIInterface mService;

    //构造方法
    public RetrofitService(Class clazz) {

        mRetrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(new CustomConverterFactory<T>(clazz))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();

        mService = mRetrofit.create(APIInterface.class);
    }

    public APIInterface getRectService() {
        if (mService != null) {
            return mService;
        }
        return null;
    }
}
